
//crypto
/*const crypto = require('crypto');
//md5 and sha1
const hash = crypto.createHash('md5');
hash.update('Jiang');
console.log(hash.digest('hex'));//hex:十六进制
//Hmac  Hmac还需要一个密钥。
const hmac = crypto.createHmac('sha256','secret-key')
hmac.update('Hello');
hmac.update('world');
console.log(hmac.digest('hex'));*/

//文件服务器
/*var
    fs = require('fs'),
    url = require('url'),
    path = require('path'),
    http = require('http');

// 从命令行参数获取root目录，默认是当前目录:
var root = path.resolve(process.argv[2] || '.');

console.log('Static root dir: ' + root);

// 创建服务器:
var server = http.createServer(function (request, response) {
    var pathname = url.parse(request.url).pathname;
    var filepath = path.join(root, pathname);
    
    fs.stat(filepath, function (err, stats) {
        if (!err && stats.isFile()) {
            console.log('200 ' + request.url);
            response.writeHead(200);
            fs.createReadStream(filepath).pipe(response);
        } else {
            console.log('404 ' + request.url);
            response.writeHead(404);
            response.end('404 Not Found');
        }
    });
});
server.listen(8080);
console.log('Server is running at http://127.0.0.1:8080/');*/
